﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools;
using 纺织贸易管理系统;

namespace 后整理管理系统.库存管理
{
    public partial class 添加信息 : Sunny.UI.UIForm
    {
        private List<StockTable> stocks = new List<StockTable>();
        public 添加信息(List<StockTable> stockTables)
        {
            InitializeComponent();
            this.stocks = stockTables;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            foreach (var item in stocks) 
            {
                item.BH=txtpingming.Text;
                item.ColorNum=txtyanse.Text;
                item.orderNum=txtordernum.Text;
                item.kuanhao=txtkuanhao.Text;
            }
            try
            {
                using (var trans = Connect.dbcontext.UseTran())
                {
                    Connect.dbcontext.Updateable(stocks).ExecuteCommand();
                    trans.CommitTran();
                    this.Close();
                }
            }
            catch (Exception ex) 
            {
                ShowMessageBox.ShowErrorBox ("保存的时候发生了错误："+ex.Message);
            }
        }
    }
}
